﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using VirtualPress.Infrastructure.Entities.Repository;
using VirtualPress.Infrastructure.Entities.Enum;

namespace VirtualPress.Infrastructure.Entities.Entity
{
    public class PeriodicalItem : IAccessible<T_PeriodicalItem, PeriodicalItem>, ILogicEntity<T_PeriodicalItem, PeriodicalItem>
    {
        #region
        public int Id { get; set; }
        public int PeriodicalId { get; set; }
        public string Manuscriptcode { get; set; }
        public DateTime PublishDate { get; set; }
        public string CoverImage { get; set; }
        public DateTime CreateDate { get; set; }
        public string Information { get; set; }
        public JournalItemStatus Status { get; set; }
        #endregion
        public List<Article> Articles { get; set; }

        protected override void Covariant(T_PeriodicalItem model)
        {
            if (model != null)
            {
                this.Id = model.Id;
                this.PublishDate = model.PublishDate;
                this.Manuscriptcode = model.Manuscriptcode;
                this.CoverImage = model.CoverImage;
                this.CreateDate = model.CreateDate;
                this.Information = model.Information;
                this.Status = (JournalItemStatus)model.Status;
                this.PeriodicalId = model.PeriodicalId;
            }
        }

        protected override T_PeriodicalItem Inverter(PeriodicalItem model)
        {
            if (model != null)
            {
                return new T_PeriodicalItem()
                {
                    Id = model.Id,
                    PublishDate = model.PublishDate,
                    Manuscriptcode=model.Manuscriptcode,
                    CoverImage=model.CoverImage,
                    CreateDate=model.CreateDate,
                    Information=model.Information,
                    Status=(int)model.Status,
                    PeriodicalId=model.PeriodicalId
                };
            }
            return null;
        }
        public PeriodicalItem Set(T_PeriodicalItem dbModel)
        {
            Covariant(dbModel);
            return this;
        }
        public PeriodicalItem SetArticles(List<Article> articles)
        {
            this.Articles = articles;
            return this;
        }
    }
}
